package cn.itcast.rabbitmq.simple;

import cn.itcast.rabbitmq.util.ConnectionUtil;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

public class Producer {
    static final String QUEUE_NAME = "simple_queue";

    public static void main(String[] args) throws Exception{
//        创建连接
       Connection connection = ConnectionUtil.getConnection();
//        创建频道
          Channel channel = connection.createChannel();
//        声明队列
        channel.queueDeclare(QUEUE_NAME,true,false,false,null);
//        发送消息
        String message = "傻吊";
        channel.basicPublish("",QUEUE_NAME,null,message.getBytes());
        System.out.println("你是："+message);
//         关闭资源
        channel.close();
        connection.close();
    }
}
